package roles;

import java.util.List;
import java.util.Optional;

/**
 * 教授类
 */
public class Professor extends User {

    public Professor(String id, String name, String account, String password) {
        super(id, name, account, password);
    }

    public Professor() {
    }

    /**
     * 检测当前教授ID是否存在
     */
    public static Professor exitProfessorId(String id, List<Professor> professorList){
        Optional<Professor> professorOptional = professorList.stream()
                .filter(professor -> professor.getId().equals(id))
                .findFirst();
        if(professorOptional.isPresent()){
            return professorOptional.get();
        }
        return null;
    }

    /**
     * 检测当前教授用户名是否存在
     */
    public static Professor exitProfessorName(String username, List<Professor> professorList){
        Optional<Professor> professorOptional = professorList.stream()
                .filter(professor -> professor.getAccount().equals(username))
                .findFirst();
        if(professorOptional.isPresent()){
            return professorOptional.get();
        }
        return null;
    }


}
